<?php

/**
 * 资讯管理
 * 
 */
namespace Blog\Controller;
use Lib\Controller;
class BlogController extends Controller {
	
	private $blog_model;
	
	public function _initialize(){
		$this->blog_model = getInstance('Blog\Model\BlogModel');		
	}

	public function index() {
		$page['currentPage'] = isset($_GET['page'])?$_GET['page']:1;
		$page['numPerPage'] = 10;
		$page['totalPage'] = ceil(count($this->blog_model->select())/$page['numPerPage']);
		$blogs = $this->blog_model->limit(($page['currentPage']-1)*10,$page['numPerPage'])->select();
		//echo '<br></br><br><br>'.$page['totalPage'];
		//echo '<br><br><br><br><br>'.count($this->blog_model->select());
		$this->assign('page',$page);
		$this->assign('blogs',$blogs);
		$this->display('Blog\View\index.php');
	}

	public function detail() {
		//$id = $_GET['id'];
		//$news = $this->blog_model->where('id='.$id)->select();
		//$this->assign('news',$news);
		$this->display('View\detail.php');
	}    
}
?>